#include "taskQueue.h"
int taskQueueInit(pTaskQueue_t pQueue){
    bzero(pQueue,sizeof(taskQueue_t));
    return 0;
}

int enTaskQueue(pTaskQueue_t pQueue, pTaskNode_t pNew){
    if (NULL == pQueue->pHead) {
        pQueue->pHead = pQueue->pTail = pNew;
    }
    else {
        pQueue->pTail->_pNext = pNew;
        pQueue->pTail = pNew;
    }

    ++pQueue->queueSize;
    return 0;
}

int getTaskNode(pTaskQueue_t pQueue,pTaskNode_t *ppGet){
    if(pQueue->queueSize == 0){
        return -1;
    }
    *ppGet = pQueue->pHead;

    pQueue->pHead = pQueue->pHead->_pNext;
    if(pQueue->queueSize == 1){
        pQueue->pTail = NULL;
    }
    --pQueue->queueSize;
    return 0;
}

int printQueue(pTaskQueue_t pQueue){
    TaskNode_t *pCur = pQueue->pHead;
    while(pCur){
        printf("%3d",pCur->_clifd);
        pCur = pCur->_pNext;
    }
    printf("\n");
    return 0;
}
